package TouristManagement;

/**
 * Interface definition : TouristOffice
 * 
 * @author OpenORB Compiler
 */
public class _TouristOfficeStub extends org.omg.CORBA.portable.ObjectImpl
        implements TouristOffice
{
    static final String[] _ids_list =
    {
        "IDL:TouristManagement/TouristOffice:1.0"
    };

    public String[] _ids()
    {
     return _ids_list;
    }

    private final static Class _opsClass = TouristManagement.TouristOfficeOperations.class;

    /**
     * Operation purchaseCard
     */
    public short purchaseCard(String name, TouristManagement.DateV startDate, TouristManagement.DateV endDate)
    {
        while(true)
        {
            if (!this._is_local())
            {
                org.omg.CORBA.portable.InputStream _input = null;
                try
                {
                    org.omg.CORBA.portable.OutputStream _output = this._request("purchaseCard",true);
                    _output.write_string(name);
                    TouristManagement.DateVHelper.write(_output,startDate);
                    TouristManagement.DateVHelper.write(_output,endDate);
                    _input = this._invoke(_output);
                    short _arg_ret = _input.read_short();
                    return _arg_ret;
                }
                catch(org.omg.CORBA.portable.RemarshalException _exception)
                {
                    continue;
                }
                catch(org.omg.CORBA.portable.ApplicationException _exception)
                {
                    String _exception_id = _exception.getId();
                    throw new org.omg.CORBA.UNKNOWN("Unexpected User Exception: "+ _exception_id);
                }
                finally
                {
                    this._releaseReply(_input);
                }
            }
            else
            {
                org.omg.CORBA.portable.ServantObject _so = _servant_preinvoke("purchaseCard",_opsClass);
                if (_so == null)
                   continue;
                TouristManagement.TouristOfficeOperations _self = (TouristManagement.TouristOfficeOperations) _so.servant;
                try
                {
                    return _self.purchaseCard( name,  startDate,  endDate);
                }
                finally
                {
                    _servant_postinvoke(_so);
                }
            }
        }
    }

    /**
     * Operation consultListeSites
     */
    public TouristManagement.InfoSite[] consultListeSites(short touristCardNumber, TouristManagement.CoordsGPS position)
    {
        while(true)
        {
            if (!this._is_local())
            {
                org.omg.CORBA.portable.InputStream _input = null;
                try
                {
                    org.omg.CORBA.portable.OutputStream _output = this._request("consultListeSites",true);
                    _output.write_short(touristCardNumber);
                    TouristManagement.CoordsGPSHelper.write(_output,position);
                    _input = this._invoke(_output);
                    TouristManagement.InfoSite[] _arg_ret = TouristManagement.listInfoSitesHelper.read(_input);
                    return _arg_ret;
                }
                catch(org.omg.CORBA.portable.RemarshalException _exception)
                {
                    continue;
                }
                catch(org.omg.CORBA.portable.ApplicationException _exception)
                {
                    String _exception_id = _exception.getId();
                    throw new org.omg.CORBA.UNKNOWN("Unexpected User Exception: "+ _exception_id);
                }
                finally
                {
                    this._releaseReply(_input);
                }
            }
            else
            {
                org.omg.CORBA.portable.ServantObject _so = _servant_preinvoke("consultListeSites",_opsClass);
                if (_so == null)
                   continue;
                TouristManagement.TouristOfficeOperations _self = (TouristManagement.TouristOfficeOperations) _so.servant;
                try
                {
                    return _self.consultListeSites( touristCardNumber,  position);
                }
                finally
                {
                    _servant_postinvoke(_so);
                }
            }
        }
    }

    /**
     * Operation consultGlobalStat
     */
    public TouristManagement.GlobalStat consultGlobalStat()
    {
        while(true)
        {
            if (!this._is_local())
            {
                org.omg.CORBA.portable.InputStream _input = null;
                try
                {
                    org.omg.CORBA.portable.OutputStream _output = this._request("consultGlobalStat",true);
                    _input = this._invoke(_output);
                    TouristManagement.GlobalStat _arg_ret = TouristManagement.GlobalStatHelper.read(_input);
                    return _arg_ret;
                }
                catch(org.omg.CORBA.portable.RemarshalException _exception)
                {
                    continue;
                }
                catch(org.omg.CORBA.portable.ApplicationException _exception)
                {
                    String _exception_id = _exception.getId();
                    throw new org.omg.CORBA.UNKNOWN("Unexpected User Exception: "+ _exception_id);
                }
                finally
                {
                    this._releaseReply(_input);
                }
            }
            else
            {
                org.omg.CORBA.portable.ServantObject _so = _servant_preinvoke("consultGlobalStat",_opsClass);
                if (_so == null)
                   continue;
                TouristManagement.TouristOfficeOperations _self = (TouristManagement.TouristOfficeOperations) _so.servant;
                try
                {
                    return _self.consultGlobalStat();
                }
                finally
                {
                    _servant_postinvoke(_so);
                }
            }
        }
    }

    /**
     * Operation consultLocalStat
     */
    public TouristManagement.LocalStat consultLocalStat(short idSite)
    {
        while(true)
        {
            if (!this._is_local())
            {
                org.omg.CORBA.portable.InputStream _input = null;
                try
                {
                    org.omg.CORBA.portable.OutputStream _output = this._request("consultLocalStat",true);
                    _output.write_short(idSite);
                    _input = this._invoke(_output);
                    TouristManagement.LocalStat _arg_ret = TouristManagement.LocalStatHelper.read(_input);
                    return _arg_ret;
                }
                catch(org.omg.CORBA.portable.RemarshalException _exception)
                {
                    continue;
                }
                catch(org.omg.CORBA.portable.ApplicationException _exception)
                {
                    String _exception_id = _exception.getId();
                    throw new org.omg.CORBA.UNKNOWN("Unexpected User Exception: "+ _exception_id);
                }
                finally
                {
                    this._releaseReply(_input);
                }
            }
            else
            {
                org.omg.CORBA.portable.ServantObject _so = _servant_preinvoke("consultLocalStat",_opsClass);
                if (_so == null)
                   continue;
                TouristManagement.TouristOfficeOperations _self = (TouristManagement.TouristOfficeOperations) _so.servant;
                try
                {
                    return _self.consultLocalStat( idSite);
                }
                finally
                {
                    _servant_postinvoke(_so);
                }
            }
        }
    }

    /**
     * Operation getIdSite
     */
    public short[] getIdSite()
    {
        while(true)
        {
            if (!this._is_local())
            {
                org.omg.CORBA.portable.InputStream _input = null;
                try
                {
                    org.omg.CORBA.portable.OutputStream _output = this._request("getIdSite",true);
                    _input = this._invoke(_output);
                    short[] _arg_ret = TouristManagement.ListShortHelper.read(_input);
                    return _arg_ret;
                }
                catch(org.omg.CORBA.portable.RemarshalException _exception)
                {
                    continue;
                }
                catch(org.omg.CORBA.portable.ApplicationException _exception)
                {
                    String _exception_id = _exception.getId();
                    throw new org.omg.CORBA.UNKNOWN("Unexpected User Exception: "+ _exception_id);
                }
                finally
                {
                    this._releaseReply(_input);
                }
            }
            else
            {
                org.omg.CORBA.portable.ServantObject _so = _servant_preinvoke("getIdSite",_opsClass);
                if (_so == null)
                   continue;
                TouristManagement.TouristOfficeOperations _self = (TouristManagement.TouristOfficeOperations) _so.servant;
                try
                {
                    return _self.getIdSite();
                }
                finally
                {
                    _servant_postinvoke(_so);
                }
            }
        }
    }

    /**
     * Operation siteVisiting
     */
    public TouristManagement.Site siteVisiting(short touristCardNumber)
    {
        while(true)
        {
            if (!this._is_local())
            {
                org.omg.CORBA.portable.InputStream _input = null;
                try
                {
                    org.omg.CORBA.portable.OutputStream _output = this._request("siteVisiting",true);
                    _output.write_short(touristCardNumber);
                    _input = this._invoke(_output);
                    TouristManagement.Site _arg_ret = TouristManagement.SiteHelper.read(_input);
                    return _arg_ret;
                }
                catch(org.omg.CORBA.portable.RemarshalException _exception)
                {
                    continue;
                }
                catch(org.omg.CORBA.portable.ApplicationException _exception)
                {
                    String _exception_id = _exception.getId();
                    throw new org.omg.CORBA.UNKNOWN("Unexpected User Exception: "+ _exception_id);
                }
                finally
                {
                    this._releaseReply(_input);
                }
            }
            else
            {
                org.omg.CORBA.portable.ServantObject _so = _servant_preinvoke("siteVisiting",_opsClass);
                if (_so == null)
                   continue;
                TouristManagement.TouristOfficeOperations _self = (TouristManagement.TouristOfficeOperations) _so.servant;
                try
                {
                    return _self.siteVisiting( touristCardNumber);
                }
                finally
                {
                    _servant_postinvoke(_so);
                }
            }
        }
    }

    /**
     * Operation existTourist
     */
    public boolean existTourist(short touristCardNumber)
    {
        while(true)
        {
            if (!this._is_local())
            {
                org.omg.CORBA.portable.InputStream _input = null;
                try
                {
                    org.omg.CORBA.portable.OutputStream _output = this._request("existTourist",true);
                    _output.write_short(touristCardNumber);
                    _input = this._invoke(_output);
                    boolean _arg_ret = _input.read_boolean();
                    return _arg_ret;
                }
                catch(org.omg.CORBA.portable.RemarshalException _exception)
                {
                    continue;
                }
                catch(org.omg.CORBA.portable.ApplicationException _exception)
                {
                    String _exception_id = _exception.getId();
                    throw new org.omg.CORBA.UNKNOWN("Unexpected User Exception: "+ _exception_id);
                }
                finally
                {
                    this._releaseReply(_input);
                }
            }
            else
            {
                org.omg.CORBA.portable.ServantObject _so = _servant_preinvoke("existTourist",_opsClass);
                if (_so == null)
                   continue;
                TouristManagement.TouristOfficeOperations _self = (TouristManagement.TouristOfficeOperations) _so.servant;
                try
                {
                    return _self.existTourist( touristCardNumber);
                }
                finally
                {
                    _servant_postinvoke(_so);
                }
            }
        }
    }

    /**
     * Operation isVisitingSite
     */
    public boolean isVisitingSite(short touristCardNumber)
    {
        while(true)
        {
            if (!this._is_local())
            {
                org.omg.CORBA.portable.InputStream _input = null;
                try
                {
                    org.omg.CORBA.portable.OutputStream _output = this._request("isVisitingSite",true);
                    _output.write_short(touristCardNumber);
                    _input = this._invoke(_output);
                    boolean _arg_ret = _input.read_boolean();
                    return _arg_ret;
                }
                catch(org.omg.CORBA.portable.RemarshalException _exception)
                {
                    continue;
                }
                catch(org.omg.CORBA.portable.ApplicationException _exception)
                {
                    String _exception_id = _exception.getId();
                    throw new org.omg.CORBA.UNKNOWN("Unexpected User Exception: "+ _exception_id);
                }
                finally
                {
                    this._releaseReply(_input);
                }
            }
            else
            {
                org.omg.CORBA.portable.ServantObject _so = _servant_preinvoke("isVisitingSite",_opsClass);
                if (_so == null)
                   continue;
                TouristManagement.TouristOfficeOperations _self = (TouristManagement.TouristOfficeOperations) _so.servant;
                try
                {
                    return _self.isVisitingSite( touristCardNumber);
                }
                finally
                {
                    _servant_postinvoke(_so);
                }
            }
        }
    }

}
